/*
 * shortestpath.h
 *
 *  Created on: Feb 27, 2011
 *      Author: tqlong
 */

#ifndef SHORTESTPATH_H
#define SHORTESTPATH_H

#include <armadillo>
#include <iostream>

struct PrintVertex {
  void operator() (int i) const { std::cout << " " << i; }
};

struct ShortestPathAdjacent
{
  std::vector<std::vector<int> > adjc_vertex_;
  std::vector<std::vector<double> > adjc_cost_;
  int s_, t_;

  // output
  double cost_;
  std::vector<int> path_;

  // other info/by-product
  std::vector<double> shortest_dist_;
  std::vector<int> prev_;

  double operator()(int s, int t);
  void load(const std::string& fname);
  void load(std::istream& is);
  void save(const std::string& fname);
  void save(std::ostream& os);
  void generate(int n, double fe);
};

struct ShortestPathMatrix
{
  arma::mat C_;

  // output
  int s_, t_;
  double cost_;
  std::vector<int> path_;

  // other info/by-product
  std::vector<double> dist_;
  std::vector<int> prev_;

  double operator()(int s, int t);
  void load(const std::string& fname) { C_.load(fname); }
  void load(std::istream& is) { C_.load(is); }
  void save(const std::string& fname) { C_.save(fname, arma::arma_ascii); }
  void save(std::ostream& os) { C_.save(os); }
  void generate(int n, double fe);
};

#endif /* SHORTESTPATH_H_ */
